import webpack from 'webpack'

import config from '../webpack.config'

const build = () => (
  new Promise((ok, fail) => {
    const compiler = webpack(config)
    compiler.run(err => {
      if (err) { console.log('BUILD CLIENT ERROR: ', err); fail(err) }
      else { console.log('BUILD CLIENT OK'); ok() }
    })
  })
  .catch(console.log)
)

export default build
